package taobaoke.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping({"/index",""})
public class HomeController {
	public HomeController() {
		System.out.println("init hello world controller");
	}

	@RequestMapping(value={"/",""},method=RequestMethod.GET)
	public ModelAndView home(Model model) {
		ModelAndView mv=new ModelAndView("index");
		return mv;
	}
	@RequestMapping(value="/getportal")
	@ResponseBody
	public List<Map<String,Object>> getPortal(Model model){
		List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
		List<Map<String,Object>> children = new ArrayList<Map<String,Object>>();
		Map<String, Object> map11 = new HashMap<String, Object>();
		Map<String, Object> map12 = new HashMap<String, Object>();
		map11.put("id", 11);
		map11.put("text", "百度");
		map11.put("attributes", "http://www.baidu.com");
		map12.put("id", 12);
		map12.put("text", "谷歌");
		map12.put("attributes", "index");
		children.add(map11);
		children.add(map12);
		Map<String, Object> map1 = new HashMap<String, Object>();
		map1.put("id", 1);
		map1.put("text", "搜索引擎");
		map1.put("state", "closed");
		map1.put("children", children);
		Map<String, Object> map2 = new HashMap<String, Object>();
		map2.put("id", 2);
		map2.put("text", "网易");
		map2.put("attributes", "http://www.163.com");
		list.add(map1);
		list.add(map2);
		return list;
	}
}